//
//  FMDBManager.swift
//  travelMapMvvm-swift2
//
//  Created by green on 15/11/2.
//  Copyright © 2015年 travelMapMvvm-swift2. All rights reserved.
//

import Foundation
import TMCommonLib

class FMDBManager {
    
//    var dataDictionaryDataSourceProtocol:DataDictionaryDataSourceProtocol = DataDictionaryDataSource.shareInstance()
    
    // MARK: - 单例
    
    class func shareInstance()->FMDBManager{
        struct YRSingleton{
            static var predicate:dispatch_once_t = 0
            static var instance:FMDBManager? = nil
        }
        dispatch_once(&YRSingleton.predicate,{
            YRSingleton.instance=FMDBManager()
        })
        return YRSingleton.instance!
    }
    
    var database : FMDatabase = {
    
        let documents   = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
        let fileURL     = documents.URLByAppendingPathComponent("travelMap.sqlite")
        
        return FMDatabase(path: fileURL.path)
    
    }()
    
    /**
     初始化数据库
     */
    func setUp() {
        
        // 初始化字典数据
//        dataDictionaryDataSourceProtocol.setUpDataDictionaryList()
    }
    
}